﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sunboxsoft.ASMS.Server.Domain.Calc
{
    class CalcUtil
    {
        /// <summary>
        /// 计算提成
        /// </summary>
        /// <param name="price"></param>
        /// <param name="commissionType"></param>
        /// <param name="commission"></param>
        /// <returns></returns>
        public static decimal CalcCommissionAmount(decimal price, int? commissionType, decimal? commission)
        {
            if (commissionType == null || commission == null)
            {
                return 0;
            }
            else if (commissionType == Constant.CommissionTypes.Fixed)
            {
                return commission.Value;
            }
            else if (commissionType == Constant.CommissionTypes.Rate)
            {
                return price * commission.Value;
            }
            return 0;
        }
    }
}
